<script setup lang="ts">
import { ref } from 'vue'

// 模拟产品数据
const products = ref([
  { id: 1, name: '产品一', description: '这是产品一的详细描述', price: 99.99 },
  { id: 2, name: '产品二', description: '这是产品二的详细描述', price: 199.99 },
  { id: 3, name: '产品三', description: '这是产品三的详细描述', price: 299.99 },
  { id: 4, name: '产品四', description: '这是产品四的详细描述', price: 399.99 },
])
</script>

<template>
  <div class="products-container">
    <h1 class="page-title">产品列表</h1>
    
    <div class="products-grid">
      <div v-for="product in products" :key="product.id" class="product-card">
        <div class="product-image">
          <!-- 产品图片占位符 -->
          <div class="image-placeholder">{{ product.name.charAt(0) }}</div>
        </div>
        <h3 class="product-name">{{ product.name }}</h3>
        <p class="product-description">{{ product.description }}</p>
        <div class="product-price">¥{{ product.price.toFixed(2) }}</div>
        <button class="add-to-cart-btn">加入购物车</button>
      </div>
    </div>
  </div>
</template>

<style scoped>
.products-container {
  max-width: 1200px;
  margin: 0 auto;
}

.page-title {
  font-size: 2rem;
  margin-bottom: 2rem;
  color: #333;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

.product-card {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
  padding: 20px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.product-image {
  width: 100%;
  height: 180px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #f5f5f5;
  border-radius: 4px;
}

.image-placeholder {
  font-size: 3rem;
  color: #999;
}

.product-name {
  font-size: 1.2rem;
  margin-bottom: 8px;
  color: #333;
}

.product-description {
  color: #666;
  margin-bottom: 12px;
  min-height: 48px;
}

.product-price {
  font-size: 1.2rem;
  font-weight: bold;
  color: #e74c3c;
  margin-bottom: 16px;
}

.add-to-cart-btn {
  width: 100%;
  padding: 10px;
  background-color: #3498db;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.add-to-cart-btn:hover {
  background-color: #2980b9;
}
</style>